from ...service.security_module import SecurityModule, FunctionName, PermissionName
from server.service.app.service_package_list import ServicePackageListService
'''
@Description: In User Settings Edit
@Author: your name
@Date: 2019-09-25 09:48:29
@LastEditTime: 2019-09-25 09:48:29
@LastEditors: your name
'''
'''
 1、服务列表服务注册
'''


def register(jsonrpc, db_addr, db_port, db_name, db_user, db_pwd, inital_password, session):
    service_package_list_service = ServicePackageListService(
        db_addr, db_port, db_name, db_user, db_pwd, inital_password, session)
    security_service = SecurityModule(
        db_addr, db_port, db_name, db_user, db_pwd, inital_password, session)

    @jsonrpc.method('IServicePackageListService.get_service_package_list')
    def __get_service_package_list():
        res = service_package_list_service.get_service_package_list()
        return res

    @jsonrpc.method('IServicePackageListService.get_service_product_package_list')
    def __get_service_product_package_list(condition, page=None, count=None):
        # permission_data = security_service.judge_permission_query(
        #     FunctionName.service_package_list, PermissionName.query)
        res = service_package_list_service.get_service_product_package_list(
            condition, page, count)
        return res
